import { request } from '@/utils/request';
import { RequestEnum } from '@/enums/httpEnum';

export const sysRoleApi = {
  roleListJson: '/sys/role/listJson',
  sysRolePage: '/sys/role/list',
  sysAddRole: '/sys/role/add',
  sysRoleUpdate: '/sys/role/update',
  deleteRole: '/sys/role/delete',
  sysRoleDetail: '/sys/role/detail',
};
export const getRoleListJson = () => {
  return request<API.RoleListResult>(
    {
      url: sysRoleApi.roleListJson,
      method: RequestEnum.GET,
    },
    {
      isGetDataDirectly: true,
    },
  );
};

export const createRole = (data: API.CreateRoleParams) => {
  return request({
    url: sysRoleApi.sysAddRole,
    method: RequestEnum.POST,
    data,
  });
};

export const updateRole = (data: API.UpdateRoleParams) => {
  return request({
    url: sysRoleApi.sysRoleUpdate,
    method: RequestEnum.PUT,
    data,
  });
};

export const deleteRole = (params: { id: number }) => {
  return request({
    url: sysRoleApi.deleteRole,
    method: RequestEnum.DELETE,
    params,
  });
};
